package com.mrjy.maintain.controller;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.BannerInfo;
import com.mrjy.maintain.bo.IBannerInfoBo;

@Controller
@RequestMapping("/maintain/bannerInfo")
public class BannerInfoController {
	
	@Autowired
	private IBannerInfoBo bannerInfoBo;
	
	
	/**
	 * 添加banner
	 * @param bannerInfo
	 * @return
	 */
	@RequestMapping(value="/insert",method=RequestMethod.POST)
	@ResponseBody
	public Object insert(BannerInfo bannerInfo,HttpSession session){
		return bannerInfoBo.insert(bannerInfo,session);
	}
	
	/**
	 * 前台获取banner列表展示
	 * @param bannerInfo
	 * @return
	 */
	@RequestMapping("/queryBannerList")
	@ResponseBody
	public Object queryBannerList(BannerInfo bannerInfo){
		return bannerInfoBo.queryBannerList(bannerInfo);
	}
	
	/**
	 * 分页查询 for back
	 * @return
	 */
	@RequestMapping("/listByPage")
	@ResponseBody
	public Object listByPage(BannerInfo bannerInfo,HttpSession session){
		return bannerInfoBo.queryByPage(bannerInfo,session);
	}
	
	/**
	 * 启用/禁用
	 * @param bannerInfo
	 * @return
	 */
	@RequestMapping("/updateDisableFlag")
	@ResponseBody
	public Object updateDisableFlag(BannerInfo bannerInfo,HttpSession session){
		return bannerInfoBo.updateDisableFlag(bannerInfo,session);
	}
	
	/**
	 * 根据ID查询
	 * @param id
	 * @return
	 */
	@RequestMapping("/queryById")
	@ResponseBody
	public Object queryById(BannerInfo bannerInfo){
		return bannerInfoBo.queryById(bannerInfo);
	}
	
	/**
	 * 更新banner
	 * @param bannerInfo
	 * @return
	 */
	@RequestMapping("/updateById")
	@ResponseBody
	public Object updateById(BannerInfo bannerInfo,HttpSession session){
		return	bannerInfoBo.updateById(bannerInfo,session);
	}
	
	/**
	 * 增加点击量
	 * @param id
	 * @return
	 */
	@RequestMapping("/addClickCount")
	@ResponseBody
	public Object addClickCount(Integer id){
		return bannerInfoBo.addClickCount(id);
	}
}
